package com.qf.kady.ssm.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: kady
 * \* Date: 2021/4/21
 * \* Time: 19:35
 * \* 千峰JAVA2101班
 * \* Description: 日期转换工具类
 * \
 */
public class DateUtil {

    public static String dateToStr(Date date, String pattern){
        String res = new SimpleDateFormat(pattern).format(date);
        return res;
    }

    public static Date strToDate(String date,String pattern){
        try {
            Date res = (Date) new SimpleDateFormat(date).parse(pattern);
            return res;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

}
